import 'package:flutter/material.dart';

class MyBottomAppBar extends StatefulWidget{
  @override
  MyBottomAppBarState createState() {
    // TODO: implement createState
    return MyBottomAppBarState();
  }
}
class MyBottomAppBarState extends State<MyBottomAppBar>{
  List<Widget> list=[
    Center(child: Icon(Icons.home,size: 220,),),
    Center(child: Icon(Icons.people,size: 220,),),
  ];
  var _currentIndex=0;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("自定义BottomAppBar"),
      ),
      body: list[_currentIndex],
      floatingActionButton: FloatingActionButton(child: Icon(Icons.add),onPressed: null,),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      bottomNavigationBar: BottomAppBar(
          shape: CircularNotchedRectangle(),
          child: Container(
            height: 50,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: <Widget>[
                Expanded(
                  child: GestureDetector(
                    child: Container(
                      decoration: BoxDecoration(),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Icon(Icons.home),
                          Text("首页")
                        ],
                      ),
                    ),
                    onTap: (){
                      setState(() {
                        _currentIndex=0;
                      });
                    },
                  ),
                ),
                Expanded(
                  child: GestureDetector(
                    child: Container(
                      decoration: BoxDecoration(),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Icon(Icons.people),
                          Text("我的")
                        ],
                      ),
                    ),
                    onTap: (){
                      setState(() {
                        _currentIndex=1;
                      });
                    },
                  ),
                ),
              ],
            ),
          )
      ),
    );
  }
}
